//
//  TKYSelectedDateView.m
//  StationHouseHelper
//
//  Created by apple on 2018/7/6.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYSelectedDateView.h"
@interface TKYSelectedDateView()

@property (nonatomic, strong)UIButton *btn;
@property (nonatomic, strong)UIImageView *imageV;
@end
@implementation TKYSelectedDateView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self tky_cornerWithRadius:0 borderColor:kMainColour borderWidth:0.5];
        self.backgroundColor = kRGBColor(248, 248, 248, 1) ;
        [self addSubview:self.dateLabel];
        [self addSubview:self.imageV];
        [self addSubview:self.btn];
        
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).with.offset(kWidthScale *5);
            make.top.equalTo(self).with.offset(kHeightScale *2.5);
            make.height.mas_equalTo(kHeightScale *20);
//            make.width.mas_equalTo(kWidthScale *100);
        }];
        
        [self.imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.dateLabel.mas_right).with.offset(kWidthScale *5);
            make.right.equalTo(self).with.offset(-kWidthScale *10);
            make.top.equalTo(self).with.offset(12);
            //make.bottom.equalTo(self).with.offset(5);
            make.width.mas_equalTo(kWidthScale *9);
            make.height.mas_equalTo(kWidthScale *5);

        }];
        
        [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).with.offset(0);
            make.top.equalTo(self).with.offset(0);
            make.left.equalTo(self).with.offset(0);
            make.bottom.equalTo(self).with.offset(0);
        }];
    }
    return self;
}

- (UILabel *)dateLabel{
    if (_dateLabel == nil) {
        _dateLabel = [[UILabel alloc]init];
        _dateLabel.text = @"2018-7-6";
        _dateLabel.font = Font(12);
        _dateLabel.textColor = kUIColorFromRGB(333333, 1);
    }
    return _dateLabel;
}

- (UIImageView *)imageV {
    if (_imageV == nil) {
        _imageV = [[UIImageView alloc]init];
        _imageV.image = [UIImage imageNamed:@"ico_listdown"];
    }
    return _imageV;
}

- (UIButton *)btn{
    if (_btn == nil) {
        _btn = [UIButton buttonWithType:UIButtonTypeCustom];
        _btn.backgroundColor = [UIColor clearColor];
        [_btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _btn;
}

- (void)click:(UIButton *)btn{
    NSLog(@"选择日历");
    if (self.selectedDateBtnBlock) {
        self.selectedDateBtnBlock(btn);
    }
}

@end
